from django.db import models
from login.models import User

# Create your models here.

class DriverAccount(models.Model):
    driver_id = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="司机ID")
    balance = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="账户余额")
    frozen_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="冻结金额")
    status = models.SmallIntegerField(choices=[(0, "禁用"), (1, "正常")], default=1, verbose_name="状态")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

class TransactionRecord(models.Model):
    driver_id = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="司机ID")
    order_id = models.BigIntegerField(blank=True, null=True, verbose_name="订单ID")
    transaction_type = models.SmallIntegerField(choices=[(0, "收入"), (1, "支出"), (2, "退款")], verbose_name="交易类型")
    amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="交易金额")
    balance = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="交易后余额")
    transaction_time = models.DateTimeField(verbose_name="交易时间")
    remark = models.CharField(max_length=255, blank=True, null=True, verbose_name="备注")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
